package com.lex.cheeseStrip.ui;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.PopupWindow;

import com.dh.cheesestrip.Util.ScreenUtil;
import com.dh.cheesestrip.Widget.TitleBar;
import com.lex.cheeseStrip.R;
import com.lex.cheeseStrip.app.BaseAct;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class PopAct extends BaseAct {

    PopupWindow popupWindow;
    @BindView(R.id.bar)
    TitleBar bar;
    @BindView(R.id.btn_show)
    Button btnShow;
    private View popupWindow_view;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pop);
        init(this);


    }

    public void initPop() {
        popupWindow_view = LayoutInflater.from(getActivity()).inflate(R.layout.pop,null);
        popupWindow = new PopupWindow(popupWindow_view, ScreenUtil.getScreenWidth(), ViewGroup.LayoutParams.MATCH_PARENT, true);
        // 设置动画效果
//        popupWindow.setAnimationStyle(R.style.Animation_ZoomLight);

        popupWindow.showAsDropDown(bar);

        //点击其他地方消失
        popupWindow_view.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                // TODO Auto-generated method stub
//                closePopupWindow();
                popupWindow.dismiss();
                return false;
            }
        });
    }


    @OnClick(R.id.btn_show)
    public void onClick() {
        initPop();

    }
}
